#pragma once
#include"HashTable.h"

namespace Tardis
{
	template<class K, class V>
	class unordered_map
	{
		struct KeyOfMap
		{
			const K& operator()(const pair<K, V>& kv)
			{
				return kv.first;
			}
		};
	public:

		typedef typename hash_bucket::HashTable<K, pair<const K, V>, KeyOfMap>::iterator iterator;
		typedef typename hash_bucket::HashTable<K, pair<const K, V>, KeyOfMap>::const_iterator const_iterator;

		iterator begin()
		{
			return _ht.begin();
		}

		const_iterator begin()const
		{
			return _ht.begin();
		}

		iterator end()
		{
			return _ht.end();
		}

		const_iterator end()const
		{
			return _ht.end();
		}

		V& operator[](const K& data)
		{
			pair<iterator, bool> ret = _ht.Insert(make_pair(data, V()));
			return (ret.first)->second;
		}

		pair<iterator, bool> insert(const pair<K, V>& kv)
		{
			return _ht.Insert(kv);
		}

	private:
		hash_bucket::HashTable<K, pair<const K, V>, KeyOfMap> _ht;
	};

}